const { contextBridge, ipcRenderer } = require('electron');

// 向渲染进程暴露安全的API
contextBridge.exposeInMainWorld('electronAPI', {
  // 协议相关API (在主进程中处理协议解析)
  protocol: {
    createCommand: (commandType, value) => ipcRenderer.invoke('protocol:createCommand', commandType, value),
    createHeartRateCommand: (action) => ipcRenderer.invoke('protocol:createHeartRateCommand', action),
    parseData: (dataArray) => ipcRenderer.invoke('protocol:parseData', dataArray),
    parseStatus: (dataArray) => ipcRenderer.invoke('protocol:parseStatus', dataArray)
  }
});